﻿package src.components 
{
	
	/**
	* 
	* Reliability project
	* -----------------------
	* @author  Dmitrij Boycov
	* @mail    dmitry.boycov@gmail.com
	* @date    April 27, 2010
	* @version 1
	* 
	*/
	
	import fl.controls.Label;
	import flash.text.TextFieldAutoSize;;
	import flash.utils.Dictionary;
	//	astra
	import com.yahoo.astra.fl.containers.Form;
	import com.yahoo.astra.containers.formClasses.FormItem;
	import com.yahoo.astra.containers.formClasses.FormLayoutStyle;
	import com.yahoo.astra.events.FormDataManagerEvent;		
	import com.yahoo.astra.fl.utils.FlValueParser;
	import com.yahoo.astra.layout.LayoutContainer;
	import com.yahoo.astra.layout.modes.BoxLayout;
	import com.yahoo.astra.managers.FormDataManager;	
	//
	import src.components.BForm; 
	 
	public class Confirm extends BForm{
		
		//protected var msg:TextArea;		
		protected var msg:Label;		
		protected var msgFormItem:FormItem; 
		protected var textMsg = "Подтверждаете действие?";
		
		public function Confirm( text="" ) {
			if( text!="" && text!=null){
				this.textMsg = text;
			}
			super("Подтверждение.");			
		}
		
		protected override function initUI() {
			this.msg = new Label();
			msg.width = 150;			
			msg.wordWrap = true;
			//msg.editable = false;
			msg.text = this.textMsg;
			msg.autoSize = TextFieldAutoSize.LEFT;
			this.createOkAndCancel();
		}
		
		protected override function initData() {			
			msgFormItem = new FormItem("", msg);
			msgFormItem.labelAlign = FormLayoutStyle.LEFT;
			msgFormItem.labelWidth = 0;			
			
			var buttons = new FormItem("", [this.okButton, this.cancelButton]);
			buttons.labelWidth = 50;	
			
			var box : BoxLayout = new BoxLayout();
			box.direction = "vertical";
			box.verticalGap = 10;			
			var itemContainer : LayoutContainer = new LayoutContainer(box);	
			itemContainer.autoMask = false;
			itemContainer.x = itemContainer.y = 30;			
			
			itemContainer.addChild(msgFormItem);			
			itemContainer.addChild(buttons);
			this.form.addChild(itemContainer);
		}
		
		public override function setData(dict: Dictionary) {
			if (dict["msg"] && dict["msg"] != null) {
				this.textMsg = dict["msg"];
				msg.text = dict["msg"];
			}else {
				msg.text =this.textMsg;
			}	
		}
	}
}